<template>
    <div class="phonechange">
        <div>
        <el-form :model="ruleForm" status-icon :rules="rules" ref="ruleForm" label-width="150px"
                 class="demo-ruleForm">
            <el-form-item label="当前手机号码：" prop="oldphone" style="width: 0px">
                <el-input v-text="ruleForm.userphone"></el-input>
            </el-form-item>
            <el-form-item label="新手机号码：" prop="newphone">
                <el-input placeholder="新手机号码" type="text" v-model="ruleForm.newphone"
                          autocomplete="off" style="width: 300px">
                </el-input>
            </el-form-item>
            <el-form-item label="验证码：" prop="code">
                <div class="code">
                    <el-input placeholder="验证码" type="text" v-model="ruleForm.code"
                              autocomplete="off" style="width: 150px"></el-input>&nbsp;
                    <el-button type="primary" >获取验证码</el-button>
                </div>
            </el-form-item>
            <el-form-item>
                <el-button type="primary" style="width: 150px" @click="submitForm('ruleForm')">保存</el-button>
            </el-form-item>
        </el-form>
    </div>
    </div>
</template>

<script>
    export default {
        name: 'phonechange',
        data() {
            return {
                ruleForm: {
                    userphone: '155****0981',
                    newphone: '',
                    code: ''
                },
                rules: {
                    newphone: [
                        {required: true, message: '请输入新手机号码', trigger: 'blur'},
                        {type: 'number', message: '请输入正确的手机号码', trigger: ['blur', 'change']}
                    ],

                }
            }
        },
        methods:{
            submitForm(formName) {
                this.$refs[formName].validate((valid) => {
                    if (valid) {
                        alert('submit!');
                    } else {
                        return false;
                    }
                });
            },
        }
    }
</script>

<style scoped>
    .code {
        display: flex;
        flex-direction: row;
        justify-content: space-around;
    }
    .phonechange {
        display: flex;
        flex-direction: row;
        justify-content: center;
        margin-top: 5%;


    }

</style>
